﻿using System;
using System.Reflection;

namespace MikeKappel.Com.CS
{
    public static partial class Helper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="element"></param>
        /// <returns></returns>
        public static T GetAttribute<T>(this MemberInfo element) where T : Attribute
        {
            return (element != null && Attribute.IsDefined(element, typeof(T)))?
                (T)Attribute.GetCustomAttribute(element, typeof(T), true) as T:
                default(T);
        }
	}
}
